#include "FWContent.h"
#include"FWGame.h"
#include<d3dx9.h>
#include"FWTexture.h"

FWContent::FWContent(void)
{
}
FWContent::FWContent(FWGame* fwgame)
{
	this->_fwGame = fwgame;
}
FWTexture* FWContent::LoadTexture(string path)
{
	FWTexture* fwtexture;
	LPDIRECT3DTEXTURE9 texture = NULL;
	D3DXIMAGE_INFO info;
	HRESULT hr;
	ZeroMemory(&info,sizeof(info));
	hr = D3DXGetImageInfoFromFile(path.c_str(),&info);
	if(hr != D3D_OK) return NULL;	
	hr = D3DXCreateTextureFromFileEx(this->_fwGame->d3dv9,
		path.c_str(),
		info.Width,
		info.Height,1,
		D3DUSAGE_DYNAMIC,
		D3DFMT_UNKNOWN,
		D3DPOOL_DEFAULT,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(255,255,255),&info,NULL,&texture);
	if(hr != D3D_OK) return NULL;
	fwtexture = new FWTexture(texture,info.Width,info.Height);
	return fwtexture;

}
FWContent::~FWContent(void)
{
}
